<?php

namespace ApiBundle\Controller\V1;

use ApiBundle\Controller\BaseController;
use FOS\RestBundle\Controller\Annotations as Rest;
use FOS\RestBundle\Controller\FOSRestController;
use Nelmio\ApiDocBundle\Annotation\ApiDoc;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use FOS\RestBundle\View\View;
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;

/**
 * @author  coffey  <coffey@nligo.com>
 *
 * 游戏类
 * Class GamesController
 * @package ApiBundle\Controller\V1
 */
class GamesController extends BaseController
{
    /**
     * @author  coffey
     * 获取游戏列表
     *
     * @ApiDoc(
     *  resource=true,
     *  description="获取游戏列表",
     *  parameters={
     *      {"name"="userToken", "dataType"="string","required"=true,"description"="用户token"},
     *  },
     * )
     * @Rest\POST("/games/list")
     */
    public function getGamesListAction(Request $request)
    {
        $rest['data'] = $this->getGamesRepository()->findAll();
        if ($rest['data'] === null) {
            return new View("there are no users exist", Response::HTTP_NOT_FOUND);
        }
        return $rest;
    }
}
